/**
 * @param {string} word1
 * @param {string} word2
 * @return {string}
 */
var mergeAlternately = function (word1, word2) {
    let str = ""
    let minLength = Math.min(word1.length, word2.length)
    for (let i = 0; i < minLength; i++) {
        str += word1[i]
        str += word2[i]
    }
    str += word1.slice(minLength)
    str += word2.slice(minLength)
    return str
};

console.log(mergeAlternately("ab", "pqrs"));
